﻿; $(function () {


    $("#toolbar").ligerToolBar({
        items: [{
            text: '上传',
            icon: '',
            id: 'btnSave',
            click: function (parameters) {
                location.href = "/Company/Photo?aid=" + $("#albumId").val();
            }
        },
            {
                text: '删除',
                icon: '',
                id: 'btnDelete',
                click: function (parameters) {

                    var rows = $(".ifunny_img_wrapper_border").size();

                    if (rows && rows.length > 0) {
                        if (confirm("删除图片，图片将无法恢复，确认删除？")) {

                            var ids = new Array();
                            $.each($(".ifunny_img_wrapper_border"), function () {
                                ids.push($(this).data("photoid"));
                            });
                            $.ajax({
                                url: '/Company/DeletePhotos',
                                dataType: 'json',
                                type: 'post',
                                data: { ids: ids.join(",") },
                                traditional: true,
                                success: function (callback) {
                                    if (callback) {
                                        $.ligerDialog.alert('删除成功', function (yes) {
                                            location.href = "/Company/Photos?aid=" + $("#albumId").val();
                                        });
                                    }
                                    else {
                                        $.ligerDialog.error('删除失败');
                                    }
                                },
                                error: function (ex) {
                                    $.ligerDialog.error('删除失败');
                                }
                            });
                        }

                    } else {
                        $.ligerDialog.alert('请选择待删除图片');
                    }


                }
            },
        {
            text: '相册列表',
            icon: '',
            id: 'btnSave',
            click: function (parameters) {
                location.href = "/Company/Albums";
            }
        }]
    });


});